//
//  SCNInvestmentModels.swift
//  ShoucainuSwift
//
//  Created by 王家旭 on 2017/3/16.
//  Copyright © 2017年 Riluee. All rights reserved.
//

import UIKit
import ObjectMapper


class SCNInvestmentViewModels: NSObject {
    
    
    func requestInvestGetInvestListNew(_ param: [String : String], successBlock:@escaping ((_ dataresult: SCNInvestmentDataresultModels) -> Void)) -> Void {
        
        SCNRequestManager.postRequest(param, URL: SCNRequestAPI.invest().getInvestListNew) { (response) in
            
            let investmentModels = Mapper<SCNInvestmentModels>().map(JSONObject: response.result.value)
            
            if let tmp = investmentModels?.dataresult {
                successBlock(tmp)
            }
        }
        
    }
}

class SCNInvestmentModels: Mappable {

    
    var dataresult: SCNInvestmentDataresultModels?
    var errmsg: String?
    var status: Int?
    var servertime: Int?
  
    init(){}
    
    required init?(map: Map) {
        mapping(map:map)
    }
    
    func mapping(map: Map) {
        
        dataresult <- map["dataresult"]
        errmsg <- map["errmsg"]
        status <- map["status"]
        servertime <- map["servertime"]
    }
    
}

class SCNInvestmentDataresultModels: Mappable {
    
    
    /// 标集合
    var list: [SCNInvestmentListModels]?

    var total: Int?
    
    
    init(){}
    
    required init?(map: Map) {
        mapping(map:map)
    }
    
    func mapping(map: Map) {
       
        list <- map["list"]

        total <- map["total"]
    }
}

class SCNInvestmentListModels: Mappable {
    
    // 这里的类型转换真恶心 ~~~
    
    // 指示标签
    var activity_icon: String?
    // 进度
    var advance: Float?
    // 担保公司
    var assure: String?
    // 描述
    var desc: String?
    // 标的图标
    var icon: String?
    // 是否新手
    var isfirsttender: NSString?
    // 是否抢标
    var istime: Int?
    // 标的时间
    var loandue: String?
    // 标的总金额
    var loanmoney: String?
    // 标的利率
    var loanrate: Int64?
    // 标的SN编号
    var loansn: String?
    // 标的状态
    var loanstatus: String?
    // 最低投标额度
    var mintendermoney: Int?
    // 返息方式
    var repay: String?
    // 招标时间
    var starttime: String?
    // 标的标题
    var title: String?
    // 是否为秒杀标
    var is_activity: String?
    // 开始时间
    var startTime: Int64?
    // 当前请求时间
    var nowTime: Int?
    // 加息前收益率
    var originrate: String?
    // 加息
    var extrarate: String?
    // 标的类型
    var markTypeId: String?
    // 特约标 状态
    var show_rmb: Int?
    
    // 剩余可投金额
    var balance: String?
    
    
    init(){}
    
    required init?(map: Map) {
        mapping(map:map)
    }
    
    func mapping(map: Map) {
        
        activity_icon <- map["activity_icon"]
        advance <- map["advance"]
        assure <- map["assure"]
        desc <- map["desc"]
        icon <- map["icon"]
        isfirsttender <- map["isfirsttender"]
        istime <- map["istime"]
        loandue <- map["loandue"]
        loanmoney <- map["loanmoney"]
        loanrate <- map["loanrate"]
        loansn <- map["loansn"]
        loanstatus <- map["loanstatus"]
        mintendermoney <- map["mintendermoney"]
        repay <- map["repay"]
        starttime <- map["starttime"]
        title <- map["title"]
        is_activity <- map["is_activity"]
        startTime <- map["start_time"]
        nowTime <- map["nowtime"]
        originrate <- map["originrate"]
        extrarate <- map["extrarate"]
        markTypeId <- map["typeid"]
        show_rmb <- map["show_rmb"]
        balance <- map["balance"]
    }
}
